package SolvedProblems;

import java.io.File;
import java.util.Scanner;
import java.util.StringTokenizer;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author Power User
 */
public class HotelAllocation11559 {

    public static void main(String args[]) {
        //File f = new File("input.txt");
        try {
            Scanner scan = new Scanner(System.in);
            //Scanner scan = new Scanner(f);
            while (scan.hasNextLine()) {
                //first line
                //--participant--budget--hotel#--weekend#
                int participant = scan.nextInt();
                int budget = scan.nextInt();
                int hotelAvailable = scan.nextInt();
                int weekendAvailable = scan.nextInt();
                scan.nextLine(); //finish this line

                int minimumCost = budget * 5;

                for (int i = 0; i < hotelAvailable; i++) {
                    int perHeadPrice = scan.nextInt();
                    scan.nextLine();
                    String hotelWeekInfo = scan.nextLine();
                    StringTokenizer strtok = new StringTokenizer(hotelWeekInfo);
                    while (strtok.hasMoreTokens()) {
                        int availableBed = Integer.parseInt(strtok.nextToken());
                        if (availableBed < participant) {
                            continue;
                        }
                        int cost = participant * perHeadPrice;
                        if (cost < minimumCost) {
                            minimumCost = cost;
                        }
                    }
                }//end for

                if (minimumCost <= budget) {
                    System.out.println(minimumCost);
                } else {
                    System.out.println("stay home");
                }
            }//end while
        } catch (Exception ex) {
        }
    }
}
